package com.cn.ant.modules.school.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.cn.ant.common.service.BaseService;
import com.cn.ant.common.persistence.Page;
import com.cn.ant.modules.school.entity.EnrollmentPlan;
import com.cn.ant.modules.school.dao.EnrollmentPlanDao;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 招生计划Service
 * @author AntDream
 * @version 2015-08-29
 */
@Service
@Transactional(readOnly = true)
public class EnrollmentPlanService extends BaseService {

    @Autowired
	private EnrollmentPlanDao enrollmentPlanDao;

	public EnrollmentPlan get(String id) {
		return enrollmentPlanDao.get(id);
	}
	
	public List<EnrollmentPlan> findList(EnrollmentPlan enrollmentPlan) {
		return enrollmentPlanDao.findList(enrollmentPlan);
	}
	
	public Page<EnrollmentPlan> findPage(Page<EnrollmentPlan> page, EnrollmentPlan enrollmentPlan) {
	    enrollmentPlan.setPage(page);
        page.setList(enrollmentPlanDao.findList(enrollmentPlan));
        return page;
	}
	
	@Transactional(readOnly = false)
	public void save(EnrollmentPlan enrollmentPlan) {
	    if (enrollmentPlan.getIsNewRecord()) {
            enrollmentPlan.preInsert();
            enrollmentPlanDao.insert(enrollmentPlan);
        } else {
            enrollmentPlan.preUpdate();
            enrollmentPlanDao.update(enrollmentPlan);
        }
	}
	
	@Transactional(readOnly = false)
	public void delete(EnrollmentPlan enrollmentPlan) {
		enrollmentPlanDao.delete(enrollmentPlan);
	}
	
}